// pages/service/order-list/index.js
var api = require("../../../../api.js"),app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentItemId: "3",
    orderNumber: '',
    startTime:'',
    endTime: '',
    data: []
  },
  onLoad: function (options) {
    /**
     * 筛选传入参数
     * orderNumber 订单号
     * startTime: 开始时间
     * endTime: 结束时间
     */
    var that =  this;
    if (options.orderNumber){
      that.setData({
        orderNumber: options.orderNumber
      });
    }
    if (options.startTime){
      that.setData({
        startTime: options.startTime
      });
    }
    if (options.endTime) {
      that.setData({
        endTime: options.endTime
      });
    }
  },
  changeSidebar: function () {
    var that = this;
    that.openSidebar();
  },
  selectSwiper: function (e) {
    var that = this;
    var val = e.currentTarget.dataset.listid;
    that.setData({
      currentItemId: val
    });
  },
  changeSwiper: function (e) {
    var that = this;
    var val = e.detail.current + 1;
    that.setData({
      currentItemId: "list-" + val
    });
  },
  list: function () {
    var that = this;
    app.request({
      url: api.default.ServerOrder,
      data: {
        bid: wx.getStorageSync('bid'),
        status: that.data.currentItemId,
        uid: wx.getStorageSync('uid')
      },
      success: function (res) {
        console.log('服务订单', res)
        var data = []
        that.setData({
          data: res.data
        })

      }
    })
  },
  onShow:function(){
   var that=this;
   that.list();
  }
})